//导入 express
const express = require('express')

//导入解析验证规则的对象
const expressJoi = require('@escook/express-joi')

//导入验证规则
const {
    add_course_schema,
    update_course_schema,
    get_course_schema,
    delete_course_schema
} = require('../schema/course')

//创建路由实例
const router = express.Router()

//导入路由处理函数 
const courseHandle = require('../router_handle/course')


//创建获取课程信息的路由规则
router.get('/getallcourses', courseHandle.getAllCourses)

//创建新增课程信息的路由规则
router.post('/addcourse', expressJoi(add_course_schema), courseHandle.addCourse)

//创建更新课程信息的路由规则
router.post('/updatecourse', expressJoi(update_course_schema), courseHandle.updateCourse)

//id获取课程信息的路由规则
router.get('/getcourse', expressJoi(get_course_schema), courseHandle.getCourseById)

//创建删除课程信息的路由规则
router.post('/deletecourse', expressJoi(delete_course_schema), courseHandle.deleteCourse)

// 创建根据课程分类获取课程信息的路由函数
router.get('/getcourses/cate', courseHandle.getCourseByCate)

//向外共享router
module.exports = router